package com.example.dotavideo.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dotavideo.R;
import com.example.dotavideo.bean.TypeBean;

public class LeftMenuAdapter extends BaseAdapter{
  
  ArrayList<TypeBean> list;
  Context context;
  
  public LeftMenuAdapter(Context context,ArrayList<TypeBean> list) {
    this.context = context;
    this.list = list;
  }
  
  @Override
  public int getCount() {
    return list != null ? list.size() : 0;
  }

  @Override
  public Object getItem(int arg0) {
    return null;
  }

  @Override
  public long getItemId(int arg0) {
    return 0;
  }

  @Override
  public View getView(int position, View view, ViewGroup group) {
    
    Holder holder;
    // 得到View
    if (view == null) {
      holder = new Holder();
      LayoutInflater inflater = LayoutInflater.from(context);
      view = inflater.inflate(R.layout.row, null);


      holder.ivIcon = (ImageView) view.findViewById(R.id.row_icon);
      holder.tvTitle = (TextView) view.findViewById(R.id.row_title);

      view.setTag(holder);
    } else {
      holder = (Holder) view.getTag();
    }


    holder.tvTitle.setText(list.get(position).getName());
    
    return view;
  }

  
  class Holder {
    public ImageView ivIcon;
    public TextView tvTitle;
  }

}
